import {
  createRouter,
  createWebHistory
} from 'vue-router'
import routes from './router'
import { useSettingStore } from '@/store/modules/setting'

const router = createRouter({
  history: createWebHistory(),
  routes
})

router.beforeEach((to, from, next) => {
  const store = useSettingStore()
  if (to.path != '/') {
    store.setNavbar(to.meta?.isNavbar || true)
    store.setTitle(to.name || '')
  } else {
    store.setNavbar(false)
    store.setTitle('')
  }
  next()
})

export default router
